<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
session_start();
if(!isset($_SESSION['id'])||empty ( $_SESSION['id'])){
    exit;
}
include 'connect.php';
include '../../functions.php';
$user_id=$_SESSION['id'];
$file_id=clear($_POST['id']);
$state=clear($_POST['do']);

if(!empty($file_id))
{
    if($state=='nofav')
    {
        $res=mysql_query("delete from `favorites` where `user_id`='$user_id' and `file_id`='$file_id'");
    }
    elseif($state=='myfav')
    {
        $res=mysql_query("insert into `favorites` set `user_id`='$user_id' , `file_id`='$file_id'");
    }
    echo $res;
}
?>
